export default {
  data() {
    const now = new Date(); // 当前日期
    const nowDayOfWeek = now.getDay(); // 今天本周的第几天
    const nowDay = now.getDate(); // 当前日
    const nowMonth = now.getMonth(); // 当前月
    const nowYear = now.getFullYear(); // 当前年
    return {
      pickerWeekStep: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          },
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          },
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          },
        }],
      },
      pickerDayStep: {
        shortcuts: [{
          text: '昨天',
          onClick(picker) {
            const time = moment().subtract(1, 'days');
            const start = time.format('YYYY-MM-DD 00:00:00');
            const end = time.format('YYYY-MM-DD 23:59:59');
            picker.$emit('pick', [start, end]);
          },
        }, {
          text: '今天',
          onClick(picker) {
            const time = moment();
            const start = time.format('YYYY-MM-DD 00:00:00');
            const end = time.format('YYYY-MM-DD 23:59:59');
            picker.$emit('pick', [start, end]);
          },
        }, {
          text: '本周',
          onClick(picker) {
            const weekStartDate = _.toTime(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + 1));
            const weekEndDate = _.toTime(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + 7, 23, 59, 59));
            picker.$emit('pick', [weekStartDate, weekEndDate]);
          },
        },
        {
          text: '上周',
          onClick(picker) {
            const weekStartDate = _.toTime(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek - 6));
            const weekEndDate = _.toTime(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek, 23, 59, 59));
            picker.$emit('pick', [weekStartDate, weekEndDate]);
          },
        },
        {
          text: '本月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * (start.getDate() - 1) - start.getHours() * 3600 * 1000 - start.getMinutes() * 60 * 1000 - start.getSeconds() * 1000);
            picker.$emit('pick', [start, end]);
          },
        },
        {
          text: '上月',
          onClick(picker) {
            const lastMonthStartDate = _.toTime(new Date(nowYear, nowMonth - 1, 1));
            const lastMonthEndDate = _.toTime(new Date(nowYear, nowMonth, 0, 23, 59, 59));
            picker.$emit('pick', [lastMonthStartDate, lastMonthEndDate]);
          },
        },
        ],
      },

    };
  },
};
